import pandas as pd
import numpy as np
# ser_obj = pd.Series(range(10))
# print(ser_obj.head(3))
# print(ser_obj.values)
# print(ser_obj.index)
# print(ser_obj[1])
# print(ser_obj * 2)
# print(ser_obj > 5)
# year_data = {2001: 17.8, 2002: 20.1, 2003: 16.5}
# ser_obj2 = pd.Series(year_data)
# print(ser_obj2.head())
# print(ser_obj2.index)
# print(ser_obj2)
# ser_obj2.name = 's'
# ser_obj2.index.name = '年份'
# print(ser_obj2.head())
# array = np.random.randn(5,6)
# print(array)
# df_obj = pd.DataFrame(array)
# print(df_obj)
# print(df_obj.head())

# dict_data = {'A': 1,
#              'B': pd.Timestamp('20170426'),
#              'C': pd.Series(1, index=list(range(4)),dtype='float32'),
#              'D': np.array([3] * 4,dtype='int32'),
#              'E': ["Python","Java","C++","C"],
#              'F': 'ITCast' }
# # print dict_data
# df_obj2 = pd.DataFrame(dict_data)
# print(df_obj2)
# print(type(ser_obj.index))
# print(type(df_obj2.index))
#
# print(df_obj2.index)

# ser_obj1 = pd.Series(range(5), index = ['a', 'b', 'c', 'd', 'e'])
# # # print(ser_obj.head())
# # # # print(ser_obj['b'])
# # # # print(ser_obj[4])
# # # print(ser_obj[1:3])
# # # print(ser_obj['b':'d'])
#
# df_obj2 = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
# # print(df_obj.head())
# # print(df_obj[['a','d']])  # 返回Series类型
# # print(df_obj[[1,3]])  # 返回DataFrame类型
# # print(type(df_obj[[0]]))  # 返回DataFrame类型
# print(ser_obj1['b':'d'])
# print(df_obj2.loc[0:2,'a'])
# print(df_obj2.iloc[0:2,0])

# df = pd.DataFrame(np.random.randn(5,4) - 1)
# # print(np.random.randn(5,4) - 1)
# print(df)
#
# print(np.abs(df))
# print(df.apply(lambda x : x.max(),axis=1))

# s4 = pd.Series(range(10, 15), index = np.random.randint(5, size=5))
# print(s4)
#
# # 索引排序
# s4.sort_index(ascending=False) # 0 0 1 3 3
# print(s4)

# ser_obj = pd.Series(range(5), index = ['a', 'b', 'c', 'd', 'e'])
# print(ser_obj.head())
# print(ser_obj['b'])
# print(ser_obj[4])
# print(ser_obj[1:3])
# print(ser_obj['b':'d'])

# ser_obj = pd.Series(np.random.randn(12),index=[
#                 ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd'],
#                 [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]])
# print(ser_obj)
# # print(type(ser_obj.index))
# # print(ser_obj.index)
# # print(ser_obj[:,2])
# print(ser_obj.swaplevel())
# print(ser_obj.swaplevel().sort_values())

# df_obj = pd.DataFrame(np.random.randn(5,4), columns = ['a', 'b', 'c', 'd'])
# print(df_obj)
# print(df_obj.describe())

# dict_obj = {'key1' : ['a', 'b', 'a', 'b',
#                       'a', 'b', 'a', 'a'],
#             'key2' : ['one', 'one', 'two', 'three',
#                       'two', 'two', 'one', 'three'],
#             'data1': np.random.randn(8),
#             'data2': np.random.randn(8)}
# def_obj = pd.DataFrame(dict_obj)
# print(def_obj)
# print(def_obj.groupby('key1'))
# print(def_obj['data1'].groupby(def_obj['key1']))
# grouped1 = def_obj.groupby('key1')
# print(grouped1.mean())
# grouped2 = def_obj['data1'].groupby(def_obj['key1'])
# print(grouped2.mean())
# print(grouped1.size())
# print(grouped2.size())
# self_def_key = [0, 1, 2, 3, 3, 4, 5, 7]
# print(def_obj.groupby(self_def_key).mean())
# print(def_obj.groupby(self_def_key).size())
# grouped2 = def_obj.groupby(['key1', 'key2'])#
# print(def_obj.groupby([def_obj['key1'], def_obj['key2']]).size())

#
# for group_name,group_data in grouped2:
#     print(group_name)
#     print(group_data)
# print(list(grouped1))
# print(dict(list(grouped1)))


# dict_obj = {'key1' : ['a', 'b', 'a', 'b',
#                       'a', 'b', 'a', 'a'],
#             'key2' : ['one', 'one', 'two', 'three',
#                       'two', 'two', 'one', 'three'],
#             'data1': np.random.randint(1, 10, 8),
#             'data2': np.random.randint(1, 10, 8)}
# df_obj = pd.DataFrame(dict_obj)
# print(df_obj)
#
# k1_sum = df_obj.groupby('key1').sum().add_prefix('sum')
# # print(k1_sum)
#
# k1_sum_merge = pd.merge(df_obj, k1_sum, lefr_on='key1', right_index=True)
# print(k1_sum_merge)

# df_obj1 = pd.DataFrame({'key': ['b', 'b', 'a', 'c', 'a', 'a', 'b'],
#                         'data1' : np.random.randint(0,10,7)})
# df_obj2 = pd.DataFrame({'key': ['a', 'b', 'd'],
#                         'data2' : np.random.randint(0,10,3)})
#
# # print(df_obj1)
# # print(df_obj2)
# print(pd.merge(df_obj1,df_obj2,on='key'))
#
# df_obj1 = df_obj1.rename(columns={'key':'key1'})
# df_obj2 = df_obj2.rename(columns={'key':'key2'})
# print(pd.merge(df_obj2,df_obj1,left_on="key2",right_on='key1'))
#
# print(pd.merge(df_obj1, df_obj2, left_on='key1', right_on='key2', how='outer'))

# ser_obj = pd.Series(np.random.randint(0,10,10))
# print(ser_obj.replace(1, -100))

# nums = [1,2,3,4,5,6,7]
# # k = 3
# # if k < len(nums):
# #     n = len(nums) - k
# #     nums1 = nums[n:]
# #     nums2 = nums[:n]
# #     nums = nums1+nums2
# # else:
# #     k = k % len(nums)
# #     n = len(nums) - k
# #     nums1 = nums[n:]
# #     nums2 = nums[:n]
# #     nums = nums1 + nums2
# # print(nums)
# x= 10
#
# print(str(x)[:(len(str(x))//2)])
# print(str(x)[(len(str(x))//2)::-1])

# s = "a good   example"
# s = s.strip()
# s = s.split(" ")
# t = " "
# a = []
# n = ""
# for i in s:
#     a.append(i)
# a.reverse()
# for i in a:
#     if i != "":
#         n = n + " " + i
# print(n)
# print(a)
# a = s.split()[::-1]
# b = s.split()
# s = " ".join(s.split()[::-1])
# print(s)
# print(a)
# print(b)

# s = ' '.join([i for i in s.split(' ') if i][::-1])
# # print(s)
# a = [1,2,3,4,5,6]
# for i in s.split(" "):
#     if i :
#         print(i)
#
# s = "Let's take LeetCode contest"
# s =s.split()
# n = ""
# for j in s:
#     t = ''.join([i for i in j][::-1])
#     n = n +" "+t
# n = n.strip()
# print(s)
# print(n)
# print(t)

# s = "()[]()"
# for i in s:
#     if i == "(":
#         if ")" not in s:
#             print(False)
#     elif i == ")":
#         if "(" not in s:
#             print(False)
#     elif i == "]":
#         if "[" not in s:
#             print(False)
#     elif i == "[":
#         if "]" not in s:
#             print(False)
#     elif i == "{":
#         if "}" not in s:
#             print(False)
#     elif i == "}":
#         if "{" not in s:
#             print(False)
#     else:
#         print(True)

# s = ["([])"]
# dic = {'{': '}',  '[': ']', '(': ')', '?': '?'}
# print(dic["("])

#
# class ListNode():
#     def __init__(self, x):
#         self.val = x
#         self.next = None
#
#
# class Solution():
#     def mergeTwoLists(self, l1, l2):
#         if l1 and l2:
#             if l1.val > l2.val:
#                 l1, l2 = l2, l1
#             l1.next = self.mergeTwoLists(l1.next, l2)
#         return l1 or l2
#
#
# x1 = ListNode([1, 2, 3])
# x2 = ListNode([1, 3, 4])
# print(type(x1), x2)
# s = Solution.mergeTwoLists(,x1,x2)
# print(s)


def hanoi(n, x, y, z):
    if n == 1:
        print(x, "-->", z)
    else:
        hanoi(n - 1, x, z, y)
        print(x, "-->", z)
        hanoi(n - 1, y, x, z)


hanoi(4, 'X', 'Y', 'Z')
